package net.roseparadise.dao.hibernate;
// default package

import net.roseparadise.dao.ArticleContentDAO;
import net.roseparadise.model.ArticleContent;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 	* A data access object (DAO) providing persistence and search support for ArticleContent entities.
 			* Transaction control of the save(), update() and delete() operations 
		can directly support Spring container-managed transactions or they can be augmented	to handle user-managed Spring transactions. 
		Each of these methods provides additional information for how to configure it for the desired type of transaction control. 	
	 * @see .ArticleContent
  * @author MyEclipse Persistence Tools 
 */

public class ArticleContentDAOImpl extends HibernateDaoSupport implements ArticleContentDAO {
    private static final Log log = LogFactory.getLog(ArticleContentDAOImpl.class);
	//property constants
	public static final String CONTENT = "content";

	protected void initDao() {
		//do nothing
	}
    
    public void save(ArticleContent transientInstance) {
        log.debug("saving ArticleContent instance");
        try {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(ArticleContent persistentInstance) {
        log.debug("deleting ArticleContent instance");
        try {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public ArticleContent findById( java.lang.Integer id) {
        log.debug("getting ArticleContent instance with id: " + id);
        try {
            ArticleContent instance = (ArticleContent) getHibernateTemplate()
                    .get("ArticleContent", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    	
    public ArticleContent merge(ArticleContent detachedInstance) {
        log.debug("merging ArticleContent instance");
        try {
            ArticleContent result = (ArticleContent) getHibernateTemplate()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

	public static ArticleContentDAOImpl getFromApplicationContext(ApplicationContext ctx) {
    	return (ArticleContentDAOImpl) ctx.getBean("ArticleContentDAO");
	}
}